﻿using System;
using System.Windows.Controls;
using System.Windows;

namespace NavFx
{
	/// <summary>
	/// Pages that hosts other pages within the NavFx framework
	/// </summary>
	public class HostPage: Page, IHostPage
	{

		#region IHostPage Members

		/// <summary>
		/// Supports other components replacing the content of this control
		/// which is not normally possible as the Content property is protected
		/// </summary>
		/// <param name="newContent">Content to replace existing</param>
		public virtual void SetContent(UserControl newContent)
		{
			base.Content = newContent;
		}

		/// <summary>
		/// Reference to the Navigator provided the host application
		/// </summary>
		/// <remarks>
		/// In this base class the Navigator provided by the Application
		/// is returned, so the set accessor is not implemented
		/// </remarks>
		public virtual Navigator Navigator
		{
			get
			{
				if(Application.Current is IApplication)
				{
					return ((IApplication)Application.Current).GetNavigator();
				}
				else
				{
					throw (new NotImplementedException());
				}
			}
			set
			{
				throw (new NotImplementedException());
			}
		}

		#endregion

		/// <summary>
		/// Default constructor required for use as an element
		/// </summary>
		public HostPage(): base()
		{
			//do nothing
		}
	}
}
